#!/bin/bash

set -e

mkdir -p out release
wget http://go-cli.s3.amazonaws.com/builds/cf-darwin-amd64 -P out
wget http://go-cli.s3.amazonaws.com/builds/cf-linux-amd64 -P out
wget http://go-cli.s3.amazonaws.com/builds/cf-linux-386 -P out
wget http://go-cli.s3.amazonaws.com/builds/cf-windows-amd64.exe -P out
wget http://go-cli.s3.amazonaws.com/builds/cf-windows-386.exe -P out

chmod +x out/cf-*

(
  cd out

  for BIN in cf-[ld]*; do
    cp ${BIN} cf
    tar cvzf ../release/${BIN}.tgz cf
    rm cf
  done

  for BIN in cf-windows*; do
    cp ${BIN} cf.exe
    zip ../release/${BIN%exe}zip cf.exe
    rm cf.exe
  done
)
